package Luogu;

import java.util.Scanner;

public class test4 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int prev=0;
        int next=0;
        int l=0;
        int count=0;
        for (int i = 0; i < n; i++) {
            next=sc.nextInt();
            //左坡形成
            if(next<prev){
                l=1;
            }
            //看右坡
            if(l==1&&next>prev){
                count++;
                l=0;
            }
            prev=next;

        }
        System.out.println(count);
    }
}
